dojo.provide("msos.colortool");
dojo.require("msos.common");
dojo.require("msos.validate");
dojo.require("dojo.i18n");
msos.colortool.generate_tool=function(_1){
this.ct_color="000000";
this.ct_path="missing.html";
this.ct_indicate_color=false;
this.after_change_function=msos.colortool.close;
this.colortool_window=null;
this.colortool_button=null;
dojo.requireLocalization("msos","colortool",djConfig.locale);
var _2=dojo.i18n.getLocalization("msos","colortool",djConfig.locale);
this.ct_button_cfg={img_name:"ed_color.gif",img_url:djConfig.msos_folder+"/images/",img_title:_2.click_title,img_alt:_2.click_alt,img_size:"img_sml",button_mouseup:null};
var _3=this;
this.open_new_window=function(){
if(msos.common.popup_cancel(_3.colortool_window)){
if(djConfig.msos_popups_blocked){
alert(_2.ct_disabled);
}else{
window.name="color_select";
_3.set_hex_color(_1.value);
var _4={ct_hex_inp:_3.ct_color};
_3.colortool_window=msos.common.open_dialog_window(_3,_3.ct_path,"colortool",185,305,_3.ct_display_color,_4);
if(djConfig.msos_popups_blocked){
alert(_2.ct_blocked);
}
}
}
};
this.ct_body_onfocus=function(_5){
msos.common.event_debug(_5,"\nColortool call page onfocus!");
msos.common.popup_cancel(_3.colortool_window);
return true;
};
this.update_onblur=function(){
var _6=_3.ct_color;
var _7=msos.validate.check_hex_color(_1.value);
if(_6.toUpperCase()!=_7.toUpperCase()){
_3.set_hex_color(_7);
_3.after_change_function(_3);
}
};
this.set_hex_color=function(_8){
_8=msos.validate.check_hex_color(_8);
if(_8=="000000"){
_1.value="#000000";
_3.ct_color="000000";
}else{
if(_8==false){
_1.value="";
_3.ct_color=null;
}else{
_1.value="#"+_8;
_3.ct_color=_8;
}
}
if(_3.ct_indicate_color&&_3.ct_color&&_3.colortool_button){
_3.colortool_button.img_elm.style.backgroundColor="#"+_3.ct_color;
}
};
this.ct_generate_button=function(){
dojo.connect(_1,"ondblclick",null,_3.open_new_window);
dojo.connect(_1,"onblur",null,_3.update_onblur);
dojo.connect(dojo.body(),"onfocus",null,_3.ct_body_onfocus);
var _9=_3.ct_button_cfg;
_9.button_mouseup=_3.open_new_window;
_3.set_hex_color(_1.value);
var _a=new msos.common.generate_img_button(_1.parentNode);
for(var _b in _9){
_a[_b]=_9[_b];
}
_a.img_button_append();
_3.colortool_button=_a;
_3.colortool_input=_1;
_1.ct_object=_3;
if(_3.ct_indicate_color){
_a.img_elm.style.backgroundColor=_1.value;
}
console.debug("ct_generate_button -> finished");
};
this.ct_display_color=function(_c){
if(!_c.ct_hex_inp){
return false;
}
_3.set_hex_color(_c.ct_hex_inp);
_3.after_change_function(_3);
return true;
};
};
msos.colortool.close=function(_d){
msos.common.popup_cancel(_d.colortool_window);
if(_d.ct_indicate_color&&_d.ct_color&&_d.colortool_button){
_d.colortool_button.img_elm.style.backgroundColor="#"+_d.ct_color;
}
_d.colortool_input.focus();
};

